var toTopBtn = document.querySelector('.toTop');
// 显示隐藏
window.onscroll = () =>{
    scrollY>300?toTopBtn.style.display = 'block':toTopBtn.style.display = 'none';
}
// 点击返顶
var timer;
toTopBtn.onclick = () =>{
    clearInterval(timer);
    timer = setInterval(()=>{
        scrollBy({top:-150});
        if(scrollY===0){
            clearInterval(timer);
        }
    },30);
}